/**
 * TODO（用一句话描述这个类做什么用）。
 * <p>
 * &lt;pre&gt;
 * 构建组：springmvc
 * 作者：wudr
 * 日期：2018/4/11 15:45
 * &lt;/pre&gt;
 */
public class test {

    public static void main(String[] args) {
        double it=1000<<1;
        int it1=5>>1;
//        System.out.println(it);
//        System.out.println(it1);
//        System.out.println(testle(1000000000));
//        System.out.println(testle2(1000));
//
//        System.out.println(bitCount(1000));
        System.out.println(highestOneBit(1000));

//        System.out.println(Integer.toBinaryString(1000000000));
//        System.out.println(Integer.toBinaryString(1073741823));
//        System.out.println(Integer.toBinaryString(1000000000).length());
//        System.out.println(Integer.toBinaryString(1073741823).length());
    }
    static  final  int testle(int no){
        int n=no-1;
        n|=n>>>1;
        n|=n>>>2;
//        n|=n>>>4;
//        n|=n>>>8;
//        n|=n>>>16;
        return n;
    }
    static  final  int testle2(int no){
        int n=no-1;
        n=n>>>1;
      /*  n=n>>>2;
        n=n>>>4;
        n=n>>>8;
        n=n>>>16;*/
        return n;
    }

    public final static int bitCount(int i) {
        // HD, Figure 5-2
        i = i - ((i >>> 1) & 0x55555555);
        i = (i & 0x33333333) + ((i >>> 2) & 0x33333333);
        i = (i + (i >>> 4)) & 0x0f0f0f0f;
        i = i + (i >>> 8);
        i = i + (i >>> 16);
        return i & 0x3f;
    }

    public final static int highestOneBit(int i) {
        // HD, Figure 3-1
        i |= (i >>  1);
        System.out.println(i);
        i |= (i >>  2);
        System.out.println(i);
        i |= (i >>  4);
        System.out.println(i);
        i |= (i >>  8);
        System.out.println(i);
        i |= (i >> 16);
        System.out.println(i);
        return i - (i >>> 1);
    }
}
